<script lang='ts' setup name='Father'>  
 import { ref ,onUnmounted} from 'vue' 


import emitter from '@/utils/emitter'

//绑定事件  定义方法
emitter.on('abc',(value)=>{

    console.log(
    '%c value: ',
    'background-color: #3756d4; padding: 4px 8px; border-radius: 2px; font-size: 14px; color: #fff; font-weight: 700;',
    value 
    )
})



function sendEvent(){
     emitter.emit('abc',new Date().getTime())
}

onUnmounted(()=>{
    emitter.off('abc')
})


</script>  
  
<template>  


        <button @click="sendEvent"> 发送消息总线事件</button>

  
</template>  
  
<style scoped>  

</style>  